package com.apes.supplier.model;

import com.apes.auto.autoparts.model.BehaviorRecord;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.party.model.PartyRole;
import com.apes.scm.masterdata.product.model.Brand;
import com.apes.scm.masterdata.product.model.Category;
import com.apes.scm.masterdata.product.model.ProductUom;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 供应商商品表
 * Created by lishikun on 2021/8/17 17:32
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = SupplierCommodity.CONST_TABLE_NAME)
public class SupplierCommodity extends Model {
    public static final String CONST_TABLE_NAME = "mas_supplier_commodity";

    @Id
    @Comment("编码")
    @Column(name = "id", nullable = false, length = 120)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "供应商商品表", padding = 8)
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "supplier_id", referencedColumnName = "id")
    @Comment("供应商")
    private PartyRole supplier;

    @Column(name = "uom_name")
    @Comment("计量单位")
    private String uomName; //计量单位

    @Comment("品牌件型号")
    @Column(name = "brand_model")
    private String brandModel;

    @Comment("品牌名称")
    @Column(name = "brand_name")
    private String brandName;

    @Comment("零件名称")
    @Column(name = "part_name")
    private String partName;

    @Comment("通用件号")
    @Column(name = "universal_part_number")
    private String universalPartNumber;

    @Comment("产品描述")
    @Column(name = "product_description")
    private String productDescription;

    @Column(name = "inventory_quantity", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("库存数量")
    private double inventoryQuantity = 0.0;

    @Column(name = "notax_price", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("报价(不含税)")
    private double notaxPrice = 0.0;

    @Comment("尺寸")
    @Column(name = "sizes")
    private String sizes;

    @Comment("产地")
    @Column(name = "origin")
    private String origin;

    @States(name = "状态", values = {
            @State(id = "up", name = "上架"),
            @State(id = "down", name = "下架")
    })
    @Column(name = "state")
    @Comment("状态(up:上架,down:下架)")
    private String state;

    @Column(name = "quality_name")
    @Comment("品质名称")
    private String qualityName;

    @Column(name = "packing_content")
    @Comment("包装含量")
    private String packingContent;

    @Column(name = "business_id")
    @Comment("商家编码")
    private String businessId;



    @Comment("替换零件号") // 对照商家编码
    @Column(name = "replacement_part_number")
    private String replacementPartNumber;

    @Comment("对照零件编码")
    @Column(name = "contrast_Part_id")
    private String contrastPartId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "contrast_brand_id", referencedColumnName = "id")
    @Comment("对照品牌")
    private Brand contrastBrand;

    @Column(name = "contrast_origin")
    @Comment("对照产地")
    private String contrastOrigin;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "category_id", referencedColumnName = "id")
    @Comment("配件名称")
    private Category category;

    @Comment("来源单号")
    private String source;

    @Column(name = "source_business_type", length = 32)
    @Comment("来源单据类型")
    private String sourceBusinessType;
}
